package com.feng.util;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
public class CommonUtils {

	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
	public static String getUUID(){
		return UUID.randomUUID().toString().replace("-", "");
	}
	public static boolean isEmpty(Collection<?> list){
		return (list==null||list.size()==0)?true:false;
	}
	public static boolean isEmpty(String str){
		return (str==null||"".equals(str))?true:false;
	}
	public static boolean isEmpty(String[] strs){
		return (strs==null||strs.length==0)?true:false;
	}
	public static boolean isEmpty(Object[] objs){
		return (objs == null||objs.length == 0)?true:false;
	}
	public static boolean isNotEmpty(Object[] objs){
		return !isEmpty(objs);
	}
	public static boolean isNotEmpty(Collection<?> list){
		return !isEmpty(list);
	}
	public static boolean isNotEmpty(String str){
		return !isEmpty(str);
	}
	public static boolean isNotEmpty(String[] strs){
		return !isEmpty(strs);
	}
	
	/**
	 * 获取当前日期+时间
	 * @return
	 */
	public static String getDateTime() {
		return sdf.format(new Date());
	}
	
	/**
	 * 获取用户id
	 * @param request
	 * @return
	 */
	public static String getCurrentUserId(HttpServletRequest request) {
		
		return (String) request.getSession().getAttribute(Dict.SESSION_USERID);
	}
	
}
